import random

def generate_mobile_numbers(count):
    prefixes = {
        "中国电信": ["133", "153", "180", "181", "189", "177", "173", "149", "199"],
        "中国联通": ["130", "131", "132", "155", "156", "185", "186", "145", "175", "176", "166"],
        "中国移动": ["134", "135", "136", "137", "138", "139", "147", "150", "151", "152", "157", "158", "159", "172", "178", "182", "183", "184", "187", "188", "198"],
    }

    mobile_numbers = set()
    while len(mobile_numbers) < count:
        operator = random.choice(list(prefixes.keys()))
        prefix = random.choice(prefixes[operator])
        suffix = "".join(random.choice("0123456789") for _ in range(8))
        mobile_number = prefix + suffix
        mobile_numbers.add((operator, mobile_number))
    
    return mobile_numbers

# 生成1000个不重复手机号码示例并保存到文件
mobile_numbers = generate_mobile_numbers(5000000)

with open("mobile_numbers.txt", "w") as file:
    for operator, mobile_number in mobile_numbers:
        # file.write(f"运营商：{operator}\n")
        file.write(f"{mobile_number}\n")
        # file.write("---\n")

print("手机号码已保存到mobile_numbers.txt文件中。")
